<?php


namespace App\Http\Controllers;

use App\Facades\ProductService;
use App\Http\Middleware\BenchMark;
use App\Http\Middleware\Test;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use App\Product;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Str;

class HomeController extends Controller
{
    public function __construct()
    {
        //$this->middleware('benchMark');
        //$this->middleware('benchMark',['only' => ['dbTest']]);
        //$this->middleware(Test::class);
        //$this->middleware('Testname:wewr');
        $this->middleware(Test::class.':wewr123');
    }

    public function hello()
    {
        echo '业务逻辑<br>';
        return 'hello1';
    }

    public function dbTest()
    {
        //$rs = DB::select('select * from users');

        //$up = DB::update('update  users set email=? where id =?',['test@123.com',1]);
        //DB::table('users')->where('id','>=',1)->dump();
        //var_dump($rs,$up);

        $insert = DB::table('users')->insert([
            [
                'name' => 'tanfandd1',
                'email' => '12ddfd31@163.com',
                'password' => Hash::make('123456'),

            ]
         ]
        );
        dd($insert);
    }

    public function modelTest()
    {
        $product= new Product();
        $product->fill();

        //$list = Product::all();
        //Product::query()->w
       // dd($list);
    }

    public function cacheTest()
    {
        /*Cache::put('test1',1);
        Cache::remember('test2','60',function (){
            return date('Y-m-d H:i:s');
        });*/
        //return Str::orderedUuid();
        $request = new Request();
<<<<<<< HEAD
=======

>>>>>>> 7aac53590da85128b4d0df7f4a6e2d7d65a34e56
        return ProductService::getInfoById($request::query('id'));

        return 5;
    }
}
